/**
 *******************************************************************************
 * @file unix_time.h
 * @author .ISS_AUTO (hudandan@issauto.com)
 * @date 2023-04-26    1. 功能接口移植MCU-N32G45X；
 *       2024-09-24    1. 更新模块接口；
 *       2024-10-30    1. 更新模块接口函数：
 *                        time_struct_data_t utc_sec_2_mytime(unsigned long utc_sec, unsigned char daylightSaving).
 *
 * @brief
 *
 * @copyright Copyright (c) 2024 ISSAUTO TECH Co., Ltd. All rights reserved.
 *
 *******************************************************************************
 */

#ifndef __UNIX_TIME_H
#define __UNIX_TIME_H

/* Private includes ----------------------------------------------------------*/
#include "main.h"

/* Exported define -----------------------------------------------------------*/
// #define utc_log(M, ...)    USER_PRINTF(""M"\r\n", ##__VA_ARGS__);
#define utc_log(M, ...)

/* Exported constants --------------------------------------------------------*/
#define UTC_BASE_YEAR      (1970)
#define MONTH_PER_YEAR     (12)
#define DAY_PER_YEAR       (365)
#define SEC_PER_DAY        (86400)
#define SEC_PER_HOUR       (3600)
#define SEC_PER_MIN        (60)

#define SEC_DIFF_Beijing   (28800)

/* Exported types ------------------------------------------------------------*/
/* time struct */
typedef struct {
    unsigned short nYear;
    unsigned char nMonth;
    unsigned char nDay;
    unsigned char nHour;
    unsigned char nMin;
    unsigned char nSec;
    unsigned char DayIndex; /* 0 = Sunday */
} time_struct_data_t;

/* Exported functions prototypes ---------------------------------------------*/
extern time_struct_data_t utc_sec_2_mytime(unsigned long utc_sec, unsigned char daylightSaving);
extern unsigned long mytime_2_utc_sec(time_struct_data_t *currTime, unsigned char daylightSaving);
extern void utc_sec_2_mytime_string(unsigned long utc_sec, char *str, unsigned int len, unsigned char daylightSaving);

extern unsigned long mytime_2_365_day(time_struct_data_t *currTime);

#endif

